<?php
/**
 * Created by PhpStorm.
 * User: sks
 * Date: 2015/12/15
 * Time: 13:49
 */

class Involved_SpecifiModel extends BaseModel{

    protected $table = 'specificate';

    /**
     *分类列表
     * @return mixed
     */
    public function CatesList()
    {

        return  DB::table($this->table)
                ->select('category.cate_name','specificate.s_id','specificate.spec_name')
                ->leftjoin('category','category.c_id', '=', 'specificate.fid')
                ->where('specificate.statue',1)
                ->get();
    }


    public function SelectCategory($id,$fids){
        return DB::table($this->table)
            ->select('cate_name')
            ->where('s_id',$fids)
            ->where('statue',1)
            ->first();
    }

    /**
     *父级分类
     * @return mixed
     */
    public function CatListfa()
    {
        return  DB::table($this->table)
            ->where('fid',0)
            ->where('statue',1)
            ->get();
    }
    /**
     *是否存在ID
     * @return mixed
     */
    public function CatFirst($id){
          $data=DB::table($this->table)
            ->where('s_id',$id)
              ->where('statue',1)
            ->first();
        //dd($data);
       return $data;
    }
    /**
     *查询是子级还是父级
     * @return mixed
     */
    public function FatherCategory($id){
        $data=DB::table($this->table)
            ->select('fid')
            ->where('s_id',$id)
            ->where('statue',1)
            ->first();
        //dd($data);
        return $data;
    }


    /**
     *查询是父级下面的子级
     * @return mixed
     */
    public function ParpentCategory($id){
        $data=DB::table($this->table)
            ->select('s_id')
            ->where('fid',$id)
            ->where('statue',1)
            ->get();
        //dd($data);
        return $data;
    }


}